<script>
  import $ from '../dfish.js'
  import WidgetBase from './WidgetBase.vue'
  import {
    h
  } from 'vue'

  export default {
    mixins: [WidgetBase],
    provide() {
      return {
        table: this
      }
    },
    methods: {
      scrollTop(y) {
        let bd = this.slotHooks.tbody
        if (bd) {
          $(bd.el).scrollToY(y)
        }
      }
    },
    computed: {
      slotHooks() {
        const a = {}
        this.slots_children().forEach(o => {
          let n = o.type.name && o.type.name.slice(2)
          if (n) {
            if (n === 'hidden') {
              (a.hiddens || (a.hiddens = [])).push(o)
            } else
              a[n] = o
          }
        })
        return a
      },
      colgroup() {
        return $.slotsChildren(this.slotHooks.columns.children).map(v => v.props)
      },
      html_class() {
        return ['f-flex-column', this.x.face && 'z-face-' + this.x.face]
      }
    }
  }
</script>
